<?php 
require_once dirname(__FILE__) . '/../../common.inc.php';
    $cond_vals = new stdClass();
    $cond_vals->c = 't.instance_id = :v1';
    $cond_vals->v = array(':v1' => $_POST['instance']);
    $result = DbUtils::get(DbUtils::createPdoInst(), 'pz_tnfp_pue_config', $cond_vals, NULL, NULL, NULL, NULL, NULL)->d;

    $obj = new stdClass();
  if(count($result)== 0){
    $obj->id = NULL;
    $obj->track_id = MiscUtils::unique();
    $obj->instance_id = $_POST['instance'];
    $obj->width = $_POST['width'];
    $obj->height = $_POST['height'];
    $obj->position = $_POST['position'];
    $obj->content = $_POST['content'];
    DbUtils::add(DbUtils::createPdoInst(), 'pz_tnfp_pue_config', $obj);
    echo " <script language=\"javascript\">history.go(-1)</script>";
  } else {
  	$obj->id = $_POST['id'];
  	$obj->width = $_POST['width'];
  	$obj->height = $_POST['height'];
    $obj->position = $_POST['position'];
    $obj->content = $_POST['content'];
    DbUtils::update(DbUtils::createPdoInst(), 'pz_tnfp_pue_config', $obj);
    echo " <script language=\"javascript\">history.go(-1)</script>";
  }
    
?>